package rensoft.android.view;

import android.app.TabActivity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.widget.TabHost.TabSpec;

public class TabActivityBase extends TabActivity {

  public TabActivityBase() {
    super();
  }

  protected void addTab(Class<?> activity_clazz, String tag, HasView view) {
    TabSpec tabSpec = getTabHost().newTabSpec(tag);
    tabSpec.setIndicator(view.asView());
    tabSpec.setContent(new Intent().setClass(this, activity_clazz));
    getTabHost().addTab(tabSpec);
  }

  protected void addTab(Class<?> activity_clazz, String tag, int label) {
    TabSpec tabSpec = getTabHost().newTabSpec(tag);
    tabSpec.setIndicator(getResources().getText(label));
    tabSpec.setContent(new Intent().setClass(this, activity_clazz));
    getTabHost().addTab(tabSpec);
  }

  protected void addTab(Class<?> activity_clazz, String tag, int label, int icon) {
    TabSpec tabSpec = getTabHost().newTabSpec(tag);
    Drawable tabIcon = getResources().getDrawable(icon);
    tabSpec.setIndicator(getResources().getText(label), tabIcon);
    tabSpec.setContent(new Intent().setClass(this, activity_clazz));
    getTabHost().addTab(tabSpec);
  }
}
